﻿#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QButtonGroup>
#include <QMainWindow>
#include "dtumanager.h"
#include "injectormanager.h"
#include "serial_driver.h"
#include "sqlthread.h"

QT_BEGIN_NAMESPACE
namespace Ui { class MainWindow; }
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

private slots:
    void showSettingDialog();
    void updateInjectorStatus();
    void showDTUHistoryDialog(int);
    void showINJHistoryDialog();
    void showDTUData(int, int);
    void exportFile(const QString& context, const QDate& date);
    void showDTUHistory(QSplineSeries*);

signals:
    void signalUpdateSetting(QList<Setting>);
    void sigSearchInj(const QDate& date);
    void sigSearchDTU(const QDateTime& time, const int id);

private:
    void routeSwitched();
    void historySwitched();

    DTUManager* dtu;
    InjectorManager* injector;
    SerialDriver* injector_port;
    SqlThread* sqlThread;
    TCPThread* tcpThread;

    QChart* historyChart;
    QValueAxis *m_axisX;
    QValueAxis *m_axisY;

    QButtonGroup* group;
    Ui::MainWindow *ui;

};
#endif // MAINWINDOW_H
